package logic

import (
	"context"
	"gorm.io/gorm"
	"huiyun/model/mysql"

	"huiyun/huiyunrpc/huiyunrpc"
	"huiyun/huiyunrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type PerfectLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPerfectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerfectLogic {
	return &PerfectLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 完善信息
func (l *PerfectLogic) Perfect(in *huiyunrpc.PerfectRequest) (*huiyunrpc.PerfectResponse, error) {
	// todo: add your logic here and delete this line
	user := mysql.User{
		Model:     gorm.Model{ID: uint(in.UserId)},
		ClassName: in.ClassName,
		Title:     in.Title,
		Image:     in.Image,
		Show:      in.Show,
	}
	mysql.DB.Debug().Where("id=?", user.ID).Updates(&user)
	return &huiyunrpc.PerfectResponse{
		UserId: int64(user.ID),
	}, nil
}
